#include "mylabel.h"
#include<QDebug>
MyLabel::MyLabel(QWidget *parent) : QLabel(parent)
{

}

void MyLabel::enterEvent(QEvent *event)
{
    (void)event;
    qDebug()<<"进入鼠标";
}

void MyLabel::leaveEvent(QEvent *event)
{
    (void)event;
    qDebug()<<"离开鼠标";
}

//屏幕左击鼠标是，打印对应的坐标值，右击时，打印屏幕的坐标
void MyLabel::mousePressEvent(QMouseEvent *event)
{
    QString str1;
    if(event->button()==Qt::LeftButton)
    {
         str1=QString("鼠标按下了，x=%1,y=%2").arg(event->x()).arg(event->y());
    }
    if(event->button()==Qt::RightButton)
    {
        str1=QString("鼠标右击按下了，屏幕坐标：x=%1,y=%2").arg(event->x()).arg(event->y());
    }
    qDebug()<<str1.toUtf8().data();
}


